package com.cqcomponents.servlets;

import java.io.IOException;
import java.io.PrintWriter;
import java.io.StringWriter;

import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpServletResponseWrapper;

public class CapturingHttpServletResponseWrapper extends
		HttpServletResponseWrapper {

	final StringWriter stringWriter = new StringWriter();

	public CapturingHttpServletResponseWrapper(HttpServletResponse response) {
		super(response);
	}

	public PrintWriter getWriter() throws IOException {
		return new PrintWriter(stringWriter);
	}

	@Override
	public ServletOutputStream getOutputStream() throws IOException {
		return null;
	}

	public String getContent() {
		return this.stringWriter.toString();
	}

}
